<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateEmployeesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('employees', function (Blueprint $table) {
            $table->increments('id');
            //$table->string("emp_no",50)->unique()->nullable(false);
            //$table->string("id_no",18)->unique()->nullable(false);
            $table->string("name",20)->nullable(false);
            $table->boolean("gender")->default(false);
            $table->date("birth_date")->nullable(true);
            $table->string('title')->nullable(true);
            $table->string('position')->nullable(true);
            $table->string('work_phone',50)->nullable(true);
            $table->string('home_phone',50)->nullable(true);
            $table->string('mobile_phone',50)->nullable(true);
            $table->string("qq",30)->nullable(true);
            $table->string("wechat",30)->nullable(true);
            $table->unsignedInteger("department_id")->nullable(true);
            $table->foreign("department_id")
                ->references("id")
                ->on('departments')
                ->onDelete("SET NULL")
                ->onUpdate("CASCADE");
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('employees');
    }
}
